<?php

class Sfs_View_Helper_StudentNameOptions
{
    function StudentNameOptions($yearSemester,$classId,$selected='',$studyCondition=null)
    {
        $student  = new Student_Model_Student();
        $tempArr = explode('-',$yearSemester);
        $year = (int)$tempArr[0];
        $semester = (int)$tempArr[1];
        $grade = $classSn = '';
        if ($classId) {
            $tempArr = explode('-',$classId);
            $grade = (int)$tempArr[0];
            $classSn = (int)$tempArr[1];
        }
        $arr = $student->getClassStudent($year,$semester,$grade,$classSn,$studyCondition);

        $str = '';
        foreach ($arr as $id=>$val){
            if ($val['sex']=='M')
            $class = "option_boy";
            else
            $class = "option_girl";
            if ($selected == $id)
            $str .=  sprintf("<option value='%d' selected class='%s'>%02d-%s</option>\n",
            $id,$class,$val['number'],$val['name']);
            else
            $str .=  sprintf("<option value='%d' class='%s'>%02d-%s</option>\n",
            $id,$class,$val['number'],$val['name']);

        }
        return $str;
    }
}
